<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-body">
                <div class="fixed-table-toolbar">
                    <div class="columns pull-right col-xs-5 col-sm-2 " role="group">
                        <button class="btn btn-primary" onclick="shelfListPrint()" id="shelfPrintBtn">
                            <i class="fa fa-print" aria-hidden="true"></i>打印
                        </button>
                    </div>
                </div>
                <div class="row">
                    <input type="hidden" id="flowLineId" th:value="${flowLineId}">
                    <input type="hidden" id="start" th:value="${start}">
                    <input type="hidden" id="end" th:value="${end}">
                    <div class="col-xs-12">
                        <div style="font-size: 12px;">
                            <table class="table table-bordered table-hover" id="dynamic-table" style="word-wrap:break-word; word-break:break-all;font-size: 9px">
                                <tbody>
                                <tr>
                                    <td colspan="8" style="text-align: center;font-weight: bold;" th:text="'【'+ ${flowLine.centreName}+ '】' + ${flowLine.flowName}+ '-散货上架单'"></td>
                                </tr>
                                <tr><td colspan="8" style="text-align: center;" th:text="'分配线路:'+ ${flowLine.carNames}"></td></tr>
                                <tr><td colspan="4" th:text="'生成时间:' + ${#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}"></td>
                                    <td colspan="2" th:text="'总数量:'+ ${productTotal}"></td><td colspan="2">负责人:</td>
                                </tr>
                                <tr>
                                    <td style="width: 8%;background: #c1c1c1;text-align: center;">货号</td>
                                    <td style="width: 26%;background: #c1c1c1;text-align: center;">品名</td>
                                    <td style="width: 8%;background: #c1c1c1;text-align: center;">规格</td>
                                    <td style="width: 8%;background: #c1c1c1;text-align: center;">数量</td>
                                    <td style="width: 8%;background: #c1c1c1;text-align: center;">货号</td>
                                    <td style="width: 26%;background: #c1c1c1;text-align: center;">品名</td>
                                    <td style="width: 8%;background: #c1c1c1;text-align: center;">规格</td>
                                    <td style="width: 8%;background: #c1c1c1;text-align: center;">数量</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript">
    $(function () {
       $.ajax({
           url:"/flowLine/manage/getShelfList",
           data:{
               flowLineId: $('#flowLineId').val(),
               start: $('#start').val(),
               end: $('#end').val()
           },
           type : "POST",
           dataType:"JSON",
           success: function (r) {
               if (r.code === 0) {
                   var shelfList = r.shelfList;
                   if (shelfList) {
                       var innerContent = "";
                       var len = shelfList.length;
                       for (var i =0; i< len; i = i+2) {
                           var item1 = shelfList[i];
                           var t1 =
                               "<td style=\"text-align: center;\">"+item1.productNo+"</td>"
                               +"<td style=\"text-align: center;\">"+ item1.name+"</td>"
                               +"<td style=\"text-align: center;\">"+ item1.skuName+"</td>"
                               +"<td style=\"text-align: center;font-weight: bold;\">"+ item1.num+"</td>";
                           var t2 ="";
                           if (i + 1 < len) {
                               var item2 = shelfList[i+1];
                               t2 =  "<td style=\"text-align: center;\">"+item2.productNo+"</td>"
                                   +"<td style=\"text-align: center;\">"+ item2.name+"</td>"
                                   +"<td style=\"text-align: center;\">"+ item2.skuName+"</td>"
                                   +"<td style=\"text-align: center;font-weight: bold;\">"+ item2.num+"</td>";
                           }
                           innerContent = innerContent +"<tr>"+t1 + t2 + "</tr>";
                       }
                       $('#dynamic-table').append(innerContent);
                   }
               } else {
                   if (r.msg) {
                       parent.layer.alert(r.msg)
                   }
               }
           }
       })
    });

    /**
     * 打印
     */
    function shelfListPrint() {
        document.getElementById('shelfPrintBtn').style.display="none";//隐藏打印按钮
        window.print();
        document.getElementById('shelfPrintBtn').style.display="inline";//隐藏打印按钮
    }
</script>
</body>
</html>